import sys
import os

# 添加项目根目录到 Python 路径
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))

import requests
from base.base_requests import MerRequests


class Marketing(MerRequests):

    def mer_coupon_save(self, name: str = ''):
        url = '/api/admin/merchant/coupon/save'

        json_data = {
            'category': 1,
            'isFixedTime': False,
            'name': name,
            'money': 1,
            'minPrice': 0,
            'day': 1,
            'isTimeReceive': False,
            'productIds': '',
            'receiveType': 2,
            'isLimited': False,
            'useStartTime': '',
            'useEndTime': '',
            'receiveStartTime': '',
            'receiveEndTime': '',
            'sort': 1,
            'total': 0,
            'status': False,
            'checked': [],
        }

        return self.post(self.mer_coupon_save.__name__, url, data=json_data)

    def mer_coupon_list(self, name: str = ''):
        url = '/api/admin/merchant/coupon/list'
        params = {
            'page': '1',
            'limit': '20',
            'status': '',
            'name': name,
            'type': '',
            'useType': '',
            'temp': '1761892854',
        }
        return self.get(self.mer_coupon_list.__name__, url, params=params)

    def mer_coupon_update(self, coupon_id, json_data=None):
        url = f'/api/admin/merchant/coupon/update/status/{coupon_id}'
        return self.post(self.mer_coupon_update.__name__, url, data=json_data)

    def mer_coupon_delete(self, coupon_id):
        url = f'/api/admin/merchant/coupon/delete/{coupon_id}'
        return self.post(self.mer_coupon_delete.__name__, url)


if __name__ == '__main__':
    mc = Marketing()
    print(mc.mer_coupon_list(name="222222"))